
// Kyle Endres
// QR Code and Envelope Experiments
// 2021 Violence Survey
// JSSAM Submission
// Stata/SE 15.1


// Figure 2 Percent participating by QR code condition
** Full Sample
ttest completion_binary, by(qrcondition)
** Pre and Post CATI with incentive
ttest completion_binary if incentive==1, by(qrcondition)
** Pre-CATI, incentive
ttest completion_binary if incentive==1 & postletter==0, by(qrcondition)
** Post-CATI, incentive
ttest completion_binary if incentive==1 & postletter==1, by(qrcondition)
** Pre-CATI, no-incentive
ttest completion_binary if incentive==0, by(qrcondition)


// Figure 3: Percent participating by envelope condition
** Full Sample
ttest completion_binary if incentive==1, by(envelope_large)
** Wireless Sample
ttest completion_binary if incentive==1 & landline==0, by(envelope_large)
** Landline Sample
ttest completion_binary if incentive==1 & landline==1, by(envelope_large)


** Wireless Sample Pre-CATI
ttest completion_binary if incentive==1 & landline==0 & postletter==0, by(envelope_large)
** Landline Sample Pre-CATI
ttest completion_binary if incentive==1 & landline==1 & postletter==0, by(envelope_large)

** Wireless Sample Post-CATI
ttest completion_binary if incentive==1 & landline==0 & postletter==1, by(envelope_large)
** Landline Sample Post-CATI
ttest completion_binary if incentive==1 & landline==1  & postletter==1, by(envelope_large)


// Table 1
logit completion_binary qrcondition i.envelope_large##landline i.postletter i.incentive
margins, dydx(qrcondition)
logit completion_binary qrcondition i.envelope_large##landline i.postletter if incentive==1
margins if landline==0, dydx(envelope)
margins if landline==1, dydx(envelope)


// Device Type (text only; no table/figure)
ttest mobile if completion_binary==1, by(qrcondition)
prtest mobile if completion_binary==1, by(qrcondition)

// Appendix


// Table A1: Sample size and response rate by condition
tab completion_binary if qrcondition==1 & envelope_large==0 & incentive==0 & postletter==0
tab completion_binary if qrcondition==0 & envelope_large==0 & incentive==0 & postletter==0

tab completion_binary if qrcondition==1 & envelope_large==0 & incentive==1 & postletter==0
tab completion_binary if qrcondition==1 & envelope_large==0 & incentive==1 & postletter==1
tab completion_binary if qrcondition==1 & envelope_large==1 & incentive==1 & postletter==0
tab completion_binary if qrcondition==1 & envelope_large==1 & incentive==1 & postletter==1

tab completion_binary if qrcondition==0 & envelope_large==0 & incentive==1 & postletter==0
tab completion_binary if qrcondition==0 & envelope_large==0 & incentive==1 & postletter==1
tab completion_binary if qrcondition==0 & envelope_large==1 & incentive==1 & postletter==0
tab completion_binary if qrcondition==0 & envelope_large==1 & incentive==1 & postletter==1


// Table A2: Logistic regression models testing balance across conditons
logit qrcondition ia_areacode1 ia_areacode2 ia_areacode3 ia_areacode4 ia_areacode5 i.county_num if completion_binary!=.
logit envelope_large ia_areacode1 ia_areacode2 ia_areacode3 ia_areacode4 ia_areacode5 i.county_num if completion_binary!=. & incentive==1


